//
//  YXJMusicCell.m
//  Piece
//
//  Created by dllo on 16/6/7.
//  Copyright © 2016年 Northeast Dianli University. All rights reserved.
//

#import "YXJMusicCell.h"
#import "UIImageView+WebCache.h"

@implementation YXJMusicCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.photoImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_photoImageView];
        
        self.musicNameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_musicNameLabel];
        
        self.nameLabel = [[UILabel alloc] init];
        self.nameLabel.textColor = [UIColor colorWithRed:0.54 green:0.74 blue:0.89 alpha:1.00];
        self.nameLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_nameLabel];
        
        self.arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"forward_info"]];
        [self.contentView addSubview:_arrowImageView];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.photoImageView.frame = CGRectMake(5, 5, 45, 45);
    self.musicNameLabel.frame = CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width + 10, self.photoImageView.frame.origin.y, 200, 20);
    self.nameLabel.frame = CGRectMake(self.musicNameLabel.frame.origin.x, self.musicNameLabel.frame.origin.y + self.musicNameLabel.frame.size.height, 200, 20);
    self.arrowImageView.frame = CGRectMake(ScreenWidth - 30, self.musicNameLabel.frame.origin.y + self.musicNameLabel.frame.size.height - 10, 10, 15);
}

-(void)setMusicModel:(YXJLikeMusicModel *)musicModel
{
    if (_musicModel != musicModel) {
        _musicModel = musicModel;
    }
    [self.photoImageView sd_setImageWithURL:[NSURL URLWithString:musicModel.authorModel.web_url] placeholderImage:[UIImage imageNamed:@"home_cover_placeholder"]];
    self.musicNameLabel.text = musicModel.authorModel.user_name;
    self.nameLabel.text = musicModel.authorModel.desc;
}
@end
